package com.sdkj.recruit.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Persistent;
import org.springframework.stereotype.Service;

import com.sdkj.recruit.dao.IMongodbDAO;
import com.sdkj.recruit.dao.IPostInformationDao;
import com.sdkj.recruit.model.PostInformation;
import com.sdkj.recruit.mongoSupport.QueryParamCreator;

@Persistent
@Service("postInformationDao")
public class PostInformationDao implements IPostInformationDao{

	@Autowired
	private IMongodbDAO dao;
	
	@Override
	public void save(PostInformation pi1) {
		dao.saveOrUpdatePO(pi1);
	}

	@Override
	public List<PostInformation> queryPostIno(String parentId, int queryType) {
		if(queryType==1) {
			return dao.getPOList(PostInformation.class, QueryParamCreator.eq("parentId", "0"));
		}
		
		if(queryType>1) {
			return dao.getPOList(PostInformation.class, QueryParamCreator.eq("parentId", parentId));
		}
		return null;
	}

	@Override
	public PostInformation queryPostByName(String f1) {
		return dao.getPO(PostInformation.class, QueryParamCreator.eq("postInformationName", f1));
	}

	@Override
	public PostInformation queryPostById(String id) {
		return dao.getPO(PostInformation.class, QueryParamCreator.eq("postInformationId", id));
	}

	@Override
	public PostInformation queryPostByName(String name, String pid) {
		return dao.getPO(PostInformation.class, QueryParamCreator.eq("postInformationName", name),QueryParamCreator.eq("parentId", pid));
	}

}
